package com.shuimin.as.model.repair;

import pond.common.S;
import pond.db.Model;

/**
 * Created by sky on 2017/7/21.
 */
public class VAsRepairOrder extends Model {
    {
        table("v_as_repair_order");
        id("id");
        field("sn");
        field("business_type");
        field("repair_type");
        field("is_appointment");
        field("arrive_time");
        field("bill_time");
        field("expected_complete_time");
        field("completed_time");
        field("service_consultant");
        field("insurance_company");
        field("inspector");
        field("receipt_id");
        field("customer_id");
        field("vehicle_id");

        field("name");
        field("send_name");
        field("send_phone");

        field("license_plate");
        field("vin");
        field("brand");
        field("model");
        field("version");
        field("mileage");

        field("receipt_sn");
        field("receipt_time");
        field("material_cost");
        field("man_hour_fee");
        field("material_fee");
        field("total_fee");
        field("integral_deduction");
        field("longka_deduction");
        field("extra_deduction");
        field("deal_fee");
        field("deposit_amount");
        field("remission_amount");
        field("gross_profit");
    }

    public AsCustomer customer(){
        AsCustomer customer=new AsCustomer();
        customer.merge(this.toMap());
        Object customer_id=this.get("customer_id");
        if(customer_id!=null) customer.setId(customer_id);
        else customer.setId(S.uuid.vid());
        this.set("customer_id",customer.id());
        return customer;
    }

    public AsVehicle vehicle(){
        AsVehicle vehicle = new AsVehicle();
        vehicle.merge(this.toMap());
        Object vehicle_id=this.get("vehicle_id");
        if(vehicle_id!=null) this.setId(vehicle_id);
        else this.setId(S.uuid.vid());
        this.set("vehicle_id",vehicle.id());
        return vehicle;
    }

    public AsRepairOrder order(){
        AsRepairOrder order = new AsRepairOrder();
        order.merge(this.toMap());
        return order;
    }

    public AsReceipt receipt(){
        AsReceipt receipt = new AsReceipt();
        receipt.merge(this.toMap());
        Object id=this.get("receipt_id");
        if(id!=null) this.setId(id);
        else this.setId(S.uuid.vid());
        this.set("receipt_id", receipt.id());
        return receipt;
    }


}
